<!DOCTYPE HTML>
<html>
	<?php
		// include 'for_test_all.php';
		 include 'for_test_all_year.php';

	//	deal();
		// @$getparm = "allStockAction.php?holdlimit={$_POST["holdlimit"]}&sta_test={$_POST["sta_test"]}&end_test={$_POST["end_test"]}&one_buy={$_POST["one_buy"]}&zhi_ying_rate={$_POST["zhi_ying_rate"]}&max_huiluo={$_POST["max_huiluo"]}&zhi_Sun={$_POST["zhi_Sun"]}&holdtime={$_POST["holdtime"]}";
		?>
<head>

<meta charset="utf-8">
<link rel="icon" href="https://jscdn.com.cn/highcharts/images/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
	.highcharts-axis-resizer {
		stroke: #eee;
	}

	.highcharts-axis-resizer:hover {
		stroke: #ccc;
	}

	#lfont {
		font-size: 10;
	}

	#bfont {
		font-size: 200;
	}

	#logo {
		width: 20%;
		height: 200px;
		float: left
	}

	#banner {
		width: 79%;
		height: 200px;
		margin-left: 1%;
		float: left
	}

	#all {
		/* background-image: url("image/1.jpg"); */
		background-color: rgb(57, 54, 218);
		/* background-color: rgb(205, 199, 231); */
		
		/* border: 2px solid #F00;
		width: 100%;
		height: 100%;
		margin: 0 auto */
	}
</style>

<!--===========================样式================================-->
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"> </script>
<link rel="icon" href="https://jscdn.com.cn/highcharts/images/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/H-ui.css" />
<title>股票回测系统</title>
</head>

<body>

<div id="all">
<!-- <header class="navbar-wrapper"></header> -->
<div class="container ui-sortable">

		<div style="width: 100%;text-align:center;height:200px; margin-top:0px;">
			<IMG id="logo" src="image/logo.jpg">
			<IMG id="banner" src="image/banner.jpg">
		</div>
		<!--===========================回测输入================================-->
		<div class="panel panel-default mt-20 ">
			<!-- <div class="panel-header">回测要求输入</div> -->
			<form action="test_all.php" method="post" enctype="multipart/form-data">
				<p style="font-family:Cambria, Cochin, Georgia, Times, 'Times New Roman', serif">
					<p style="font-size: 18px;  padding-left:30px; font-weight:550;  ">选择您想回测的时间区间：</p>

					<div style="padding-left:30px; padding-right:50px; padding-bottom:10px; float:left; ">开始时间

						<input name="sta_test" type="date" value="2016-01-10" />
					</div>
					<div style="padding-right:100px; padding-bottom:10px; float:left;">结束时间

						<input name="end_test" type="date" value="2016-03-20" />
					</div>
					<div style="padding-right:100px; padding-bottom:10px;"><a href="only_train.php" style="font-size:25px; color:#1296db">返回>>只训练模式</a>
					</div>
				</p>
				<p>
					<span style="text-align:center;">
						<hr style=" width:100%;"></span>
				</p>

				<p>
					<p style="font-family:Cambria, Cochin, Georgia, Times, 'Times New Roman', serif">
                        <p style="font-size: 18px;  padding-left:30px; font-weight:550;  float:left; ">输入回测条件：
                        <div style="text-align: center; font-size: 20px;  padding-left:30px; font-weight:550; color:#1296db ">多日训练方法：</div></p>
						<div style="padding-left:50px; padding-right:100px;   padding-bottom:10px; float:left;"><img src="image/1.png" style="padding-right:15px;"><span id="bfont"><b>时机：</b></span>开盘买入</div>

						<div style=" padding-right:30px; padding-bottom:10px;  float:left;">
							<img src="image/1.png" style="padding-right:15px;"><b>持股天数</b>
							<!-- 
								<input type="text" name="holdtime" size="12" value="2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20" /></div>
							-->
							<input type="text" name="holdtime" size="12" value="2,3,4,5" /></div>
						<div style="padding-left:60px; padding-right:80px; padding-bottom:10px; float:left;">
							<img src="image/1.png" style="padding-right:15px;"><b>持股上限：</b>
							<select name="holdlimit" style="width: 60px">
								<option value="1">1</option>
								<option value="2">2</option>
								<option value="3" selected>3</option>
								<option value="4">4</option>
								<option value="5">5</option>
								<option value="6">6</option>
								<option value="7">7</option>
								<option value="8">8</option>
							</select></div>
						<div style="padding-left:30px; padding-right:10px; padding-bottom:10px;  ">
							<img src="image/1.png" style="padding-right:15px;"><b>单日买入数：</b>
							<select name="one_buy" style="width: 60px">

								<option value="1">1</option>
								<option value="2" selected>2</option>
								<option value="3">3</option>
								<option value="4">4</option>
								<option value="5">5</option>
								<option value="6">6</option>
								<option value="7">7</option>
								<option value="8">8</option>
							</select></div>
					</p>
					<p>
						<div style="padding-left:50px; padding-right:30px;   padding-bottom:10px; float:left;">
							<img src="image/1.png" style="padding-right:15px; "><b>止盈</b>：收益率&gt;=
							<input type="text" name="zhi_ying_rate" size="3" value=20 />%</div>
						<div style=" padding-right:30px; padding-bottom:10px;  float:left;">
							<img src="image/1.png" style="padding-right:0px;">持有，直到收益回落
							<input type="text" name="max_huiluo" size="3" value=10 />%</div>
					</p>
					<p>
						<div style="padding-right:10px; padding-bottom:10px; float:left;">
							<img src="image/1.png" style="padding-right:50px;"><b>止损</b>：收益率
							<= <input type="text" name="zhi_Sun" size="6" value=-7 />%</div>
						<div style="padding-left:20px; padding-right:30px; padding-bottom:10px; ">
							<img src="image/1.png" style="padding-left:50px; padding-right:15px;"><b>排序方式</b>：
							<select name="order" style="width: 100px">
								<option value="ts_code" selected>股票代码</option>
								<option value="bkdm">板块代码</option>
								<option value="polocy1_5"> 前5天每日排名 </option>
								<option value="polocy1_10">前10天每日排名</option>
								<option value="polocy1_20"> 前20天每日排名</option>
								<option value="polocy1_30">前30天每日排名</option>
								<option value="polocy1_60"> 前60天每日排名</option>
								<option value="polocy2_5"> 前5天每日积分 </option>
								<option value="polocy2_10">前10天每日积分</option>
								<option value="polocy2_20"> 前20天每日积分</option>
								<option value="polocy2_30">前30天每日积分</option>
								<option value="polocy2_60"> 前60天每日积分</option>
							</select></div>

							<div style="padding-left:350px; padding-right:0px; padding-bottom:10px;float:left; ">
							<img src="image/1.png" style="padding-right:15px;"><b>比较方式</b>：
							<select name="compareWay" style="width: 100px">
								<option value="chuangyeban" selected>创业板指</option>
								<option value="hushen300">沪深300</option>
								<option value="shangzheng50"> 上证50</option>
								<option value="shangzhengzhishu">上证指数</option>
								<option value="shenzhengchengzhi">深圳成指</option>
								<option value="zhongxiaobanzhi">中小板指</option>
								<option value="zhongzheng500"> 中证500</option>
							</select></div>
						</p>

						<p>
						<div style="padding-left:80px; padding-right:0px;   padding-bottom:10px; float:left;">
							<img src="image/1.png" style="padding-right:15px; "><b>增量值：</b>
							<input type="text" name="increment" size="5" value=3 /></div>
						</p>
						
						</p>
							<div style="padding-left:1100px;">
								<button type="submit" name="dosubmit" value="回测" style="background-color:#1296db;width:100px;height:25px;"><div style="color:#ffffff;">开始回测</div></button>
							</div>
						</p>
			</form>
		</div>

		<!--===========================测试集回测分析================================-->
	
		<div class="panel panel-default mt-20 ">
			<div class="panel-header">训练集回测分析</div>
			<table class="table table-border table-bordered table-striped mt-20">
				<thead>
					<tr>
						<th class="col1">训练时间区间</th>
						<th class="col1">持股周期</th>
						<th class="col1">年化收益率</th>
						<th class="col1">真实收益率</th>
						<th class="col1">最大回撤</th>
						<th class="col1">夏普比率</th>
						<th class="col1">MAR比率</th>

						<th class="col2">单次平均收益</th>
						<th class="col1">单次最大收益率</th>
						<th class="col2">单次最小收益率</th>
						<th class="col3">交易次数</th>
					</tr>
				</thead>

				<?php
				if ($train_save != null) {
					for($i = 0;$i < count($train_save); $i++){
						echo '<tbody >
						<tr >
							<td class="col2" >
							' . $train_save[$i]["start_day"] . '~'.$train_save[$i]["end_day"].'
							</br>
							<span style="color:red">' . $test_save[$i]["start_day"] . '~'.$test_save[$i]["end_day"].'</span>
							</td>
						  <td class="col2" >' . $train_save[$i]["holdtime"] . '天
						  </br>
						  <span style="color:red">' . $test_save[$i]["holdtime"] . '天</span>
						  </td>
						  <td class="col2" >' . $train_save[$i]["year_shouyi"] . '%
						  </br>
						  <span style="color:red">' . $test_save[$i]["year_shouyi"] . '%</span>
						  </td>    
						  <td class="col2" >' . $train_save[$i]["real_shouyilv"] . '%
						  </br>
						  <span style="color:red">' . $test_save[$i]["real_shouyilv"] . '%</span>
						  </td> 
						  <td class="col2" >' . $train_save[$i]["max_huice"] . '%
						  </br>
						  <span style="color:red">' . $test_save[$i]["max_huice"] . '%</span>
						  </td>
						  <td class="col2" >' . $train_save[$i]["xiapu_rate"] . '
						  </br>
						  <span style="color:red">' . $test_save[$i]["xiapu_rate"] . '</span>
						  </td> 
						  <td class="col2" >' . $train_save[$i]["Mar_rate"] . '
						  </br>
						  <span style="color:red">' . $test_save[$i]["Mar_rate"] . '</span>
						  </td> 
				          
						  <td class="col3" >' . $train_save[$i]["ave_shouyi"] . '%
						  </br>
						  <span style="color:red">' . $test_save[$i]["ave_shouyi"] . '%</span>
						  </td>
						  <td class="col2" >' . $train_save[$i]["max_shouyi"] . '%
						  </br>
						  <span style="color:red">' . $test_save[$i]["max_shouyi"] . '%</span>
						  </td>
						  <td class="col3" >' . $train_save[$i]["min_shouyi"] . '%
						  </br>
						  <span style="color:red">' . $test_save[$i]["min_shouyi"] . '%</span>
						  </td>
						  <td class="col2" >' . $train_save[$i]["trade_times"] . '
						  </br>
						  <span style="color:red">' . $test_save[$i]["trade_times"] . '</span>
						  </td>           
						</tr>
					  </tbody>';
					}
					
				
			}
				?>
			</table>
		</div>
			<!--===========================训练集回测分析================================-->
		<!-- 
		<div class="panel panel-default mt-20 ">
			<div class="panel-header">测试过程回测分析</div>
			<table class="table table-border table-bordered table-striped mt-20">
				<thead>
					<tr>
						<th class="col1">测试时间区间</th>
						<th class="col1">持股周期</th>
						<th class="col1">年化收益率</th>
						<th class="col1">真实收益率</th>
						<th class="col1">最大回撤</th>
						<th class="col1">夏普比率</th>
						<th class="col1">MAR比率</th>

						<th class="col2">单次平均收益</th>
						<th class="col1">单次最大收益率</th>
						<th class="col2">单次最小收益率</th>
						<th class="col3">交易次数</th>
					</tr>
				</thead>

				<?php
				/*
				if (@$test_save != null) {
					for($i = 0;$i < count($test_save); $i++){
						echo '<tbody >
									  <tr >
									    <td class="col2" style="color: red;">' . $test_save[$i]["start_day"] . '~'.$test_save[$i]["end_day"].'</td>
										<td class="col2" style="color: red;">' . $test_save[$i]["holdtime"] . '天</td>
										<td class="col2" style="color: red;">' . $test_save[$i]["year_shouyi"] . '%</td>    
										<td class="col2" style="color: red;">' . $test_save[$i]["real_shouyilv"] . '%</td> 
										<td class="col2" style="color: red;">' . $test_save[$i]["max_huice"] . '%</td> 
										<td class="col2" style="color: red;">' . $test_save[$i]["xiapu_rate"] . '</td> 
										<td class="col2" style="color: red;">' . $test_save[$i]["Mar_rate"] . '</td> 
										 
										<td class="col3" style="color: red;">' . $test_save[$i]["ave_shouyi"] . '%</td>
										<td class="col2" style="color: red;">' . $test_save[$i]["max_shouyi"] . '%</td>
										<td class="col3" style="color: red;">' . $test_save[$i]["min_shouyi"] . '%</td>
										<td class="col2" style="color: red;">' . $test_save[$i]["trade_times"] . '</td>           
									  </tr>
							 </tbody>';
					}
				}
				*/?>
			</table>
		</div>
		-->
		<!-- **********************饼状图的处理***************** -->
		<script type="text/javascript" language="javascript">
		var dataJSON = [];
		var JsonHistory = [];
		var bingJSON = [];
        dataJSON = <?php echo $line_json_string;?>		
		window.localStorage.setItem('jsonDataLine',JSON.stringify(dataJSON))		

        JsonHistory = <?php echo $his_json_string;?>
		// console.log(JsonHistory)
		window.localStorage.setItem('jsonDataHis', JSON.stringify(JsonHistory))
		bingJSON = <?php echo $bing_json_string;?>    // 获取数据		
		
			function selectData(x) {
				console.log(document.getElementById("selectDate").value)
				var dateValue = document.getElementById("selectDate").value
				switch (true) {
					case dateValue == 2:
						childJSON = bingJSON[0]['day:2']
						break
					case dateValue == 3:
						childJSON = bingJSON[1]['day:3']
						break
					case dateValue == 4:
						childJSON = bingJSON[2]['day:4']
						break
					case dateValue == 5:
						childJSON = bingJSON[3]['day:5']
						break
						// case dateValue == 6:
						// document.getElementById("div1").src = '6.html'
						// break
						// case dateValue == 7:
						// document.getElementById("div1").src = '7.html'
						// break
						// case dateValue == 8:
						// document.getElementById("div1").src = '8.html'
						// break
						// case dateValue == 9:
						// document.getElementById("div1").src = '9.html'
						// break
				}
				showModal(childJSON)
			}
			function noModal(x) {
				document.getElementById("div1").innerHTML = '';

			}
			function showModal(childJSON) {
				console.log('8888888', childJSON)

				document.getElementById("div1").src = ''
				//建仓
				window.localStorage.setItem('jsonData', JSON.stringify(childJSON))

				document.getElementById("div1").src = '2.html'
				// document.getElementById("div1").innerHTML = '<object type="text/html" data="2.html" width="600px" height="430px" border="1px red solid"></object>'

			}


		</script>

		<!-- **************************************折线图的处理****************** -->
		
		<!--===========================累积收益图================================-->
		<div class="panel panel-default mt-20">
			<div class="panel-header">折线图</div>
		<iframe src="line33.php" id="div2" name="div2" allowTransparency="true" width="100%" height="430" scrolling="no" frameborder="0"></iframe>
		</div>
		<!--===========================涨跌幅分布================================-->
		<div class="panel panel-default mt-20">
			<div class="panel-header">饼状图</div>
			<select id="selectDate" onchange="selectData()" style="float: right;margin-top: 20px;">
				<option value="2"> 2天 </option>
				<option value="3"> 3天 </option>
				<option value="4"> 4天 </option>
				<option value="5"> 5天 </option>
				<option value="6"> 6天 </option>
				<option value="7"> 7天 </option>
				<option value="8"> 8天 </option>
				<option value="9"> 9天 </option>
			</select>
			<iframe src="2.html" id="div1" name="div1" allowTransparency="true" width="100%" height="400" scrolling="no" frameborder="0"></iframe>
		</div>
		<!--===========================柱状图分布================================-->

		<!--===========================历史明细查询================================-->
		
		<div class="panel panel-default mt-20">
			<div class="panel-header">历史明细查询</div>
            <iframe src="show.html" id="div3" name="div2" allowTransparency="true" width="100%" height="400" frameborder="0"></iframe>
		</div>

		<!--===========================历史明细查询================================-->

		<footer class="footer mt-20"></footer>
	</div>

	<?php
	$newSql->closeDatabase();
	?>
</body>

</html>